package android.demo;

import android.app.Activity;
import android.content.Intent;
import android.content.res.Configuration;
import android.demo.Constants.Tag;
import android.os.Bundle;
import android.util.Log;
import android.widget.LinearLayout.LayoutParams;

public abstract class BaseActivity extends Activity {

	protected final String TAG = Tag.ACTIVITY;
    protected final LayoutParams wrapContent = new LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT);
	
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		Log.i(TAG, this + "@" + this.getTaskId() + " ................onCreate");
	}

	@Override
	protected void onNewIntent(Intent intent) {
		super.onNewIntent(intent);
		Log.i(TAG, this + "@" + this.getTaskId() + " ................onNewIntent");
	}
	
	protected void onStart() {
		super.onStart();
		Log.i(TAG, this + "@" + this.getTaskId()  + " ................onStart");
	}

	
	protected void onRestart() {
		super.onRestart();
		Log.i(TAG, this + "@" + this.getTaskId()  + " ................onRestart");
	}

	
	protected void onResume() {
		super.onResume();
		Log.i(TAG, this + "@" + this.getTaskId()  + " ................onResume");
	}

	
	protected void onPause() {
		super.onPause();
		Log.i(TAG, this + "@" + this.getTaskId()  + " ................onPause");
	}

	
	protected void onStop() {
		super.onStop();
		Log.i(TAG, this + "@" + this.getTaskId()  + " ................onStop");
	}

	
	protected void onDestroy() {
		super.onDestroy();
		Log.i(TAG, this + "@" + this.getTaskId()  + " ................onDestroy");
	}
	
	@Override
	protected void onSaveInstanceState(Bundle outState) {
		super.onSaveInstanceState(outState);
		Log.d(TAG, this + "@" + this.getTaskId()  + " ................onSave");
	}
	
	@Override
	protected void onRestoreInstanceState(Bundle savedInstanceState) {
		super.onRestoreInstanceState(savedInstanceState);
		Log.d(TAG, this + "@" + this.getTaskId()  + " ................onRestore");
	}
	
	// 需在AndroidManifest里注册Activity的configChanges属性
	@Override
	public void onConfigurationChanged(Configuration newConfig) {
		super.onConfigurationChanged(newConfig);
		Log.d(TAG, this + "@" + this.getTaskId()  + " ................onConfigurationChanged");
		if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
			Log.d(TAG, this + "@" + this.getTaskId()  + " ................orientation_landscape");
		} else if (newConfig.orientation == Configuration.ORIENTATION_PORTRAIT) {
			Log.d(TAG, this + "@" + this.getTaskId()  + " ................orientation_portrait");
		}
	}
}
